package com.sgy.springboot_demo.aspect;

import com.sgy.springboot_demo.annotation.Routingwith;
import com.sgy.springboot_demo.config.RoutingDataSourceContext;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class RoutingAspect {

    @Around("@annotation(routingwith)")
    public Object routingwithDataSource(ProceedingJoinPoint joinPoint, Routingwith routingwith) throws Throwable {
        RoutingDataSourceContext routingDataSourceContext = new RoutingDataSourceContext(routingwith.value());
        return joinPoint.proceed();
    }
}
